package com.secure.common.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 将request和response放入本地线程堆栈
 */
public class WebUtil {
	
	private static final ThreadLocal<HttpServletRequest> requestLocal = new ThreadLocal<HttpServletRequest>();
	
	private static final ThreadLocal<HttpServletResponse> responseLocal = new ThreadLocal<HttpServletResponse>();
	
	public static void setRequest(HttpServletRequest request){
		requestLocal.set(request);
	}
	
	public static HttpServletRequest getRequest(){
		return requestLocal.get();
	}
	
	public static void setResponse(HttpServletResponse response){
		responseLocal.set(response);
	}
	
	public static void setRequestResponse(HttpServletRequest request, HttpServletResponse response){
		requestLocal.set(request);
		responseLocal.set(response);
	}
	
	public static HttpServletResponse getResponse(){
		return responseLocal.get();
	}
}
